# Maintainer: Junjie Mao <eternal.n08@gmail.com>

_realname=libart_lgpl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.3.21
pkgrel=2
pkgdesc="Library for high-performance 2D graphics (mingw-w64)"
depends=()
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://www.levien.com/libart'
license=('custom')
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.bz2"
        "0001-Fix-an-installation-path-bug.patch")
sha256sums=('fdc11e74c10fc9ffe4188537e2b370c0abacca7d89021d4d303afdf7fd7476fa'
            '730eca896d981b5c8e6d65e96ceededed6e08068c8b6f29a782d7b56ddae92d6')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-Fix-an-installation-path-bug.patch
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
     --prefix=${MINGW_PREFIX} \
     --exec-prefix=${MINGW_PREFIX} \
     --build=${MINGW_CHOST} \
     --host=${MINGW_CHOST} \
     --target=${MINGW_CHOST} \
     --enable-static \
     --enable-shared

  cp ../${_realname}-${pkgver}/libart.def libart.def
  make
}

check() {
  # The package ships with some test tools but provides no automatic check mechanisms
  plain "skip"
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"

  cd "${srcdir}"/${_realname}-${pkgver}
  [[ -f COPYING ]] && install -Dm644 COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
  [[ -f AUTHORS ]] && install -Dm644 AUTHORS ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/AUTHORS
  [[ -f NEWS ]] && install -Dm644 NEWS ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/NEWS
}
